package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.exception.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TenancyInfoMapper;
import com.ruoyi.system.domain.TenancyInfo;
import com.ruoyi.system.service.ITenancyInfoService;

/**
 * 租户信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-03-03
 */
@Service
public class TenancyInfoServiceImpl implements ITenancyInfoService 
{
    @Autowired
    private TenancyInfoMapper tenancyInfoMapper;

    /**
     * 查询租户信息
     * 
     * @param id 租户信息主键
     * @return 租户信息
     */
    @Override
    public TenancyInfo selectTenancyInfoById(Long id)
    {
        return tenancyInfoMapper.selectTenancyInfoById(id);
    }

    /**
     * 查询租户信息列表
     * 
     * @param tenancyInfo 租户信息
     * @return 租户信息
     */
    @Override
    public List<TenancyInfo> selectTenancyInfoList(TenancyInfo tenancyInfo)
    {
        return tenancyInfoMapper.selectTenancyInfoList(tenancyInfo);
    }

    /**
     * 新增租户信息
     * 
     * @param tenancyInfo 租户信息
     * @return 结果
     */
    @Override
    public int insertTenancyInfo(TenancyInfo tenancyInfo)
    {

        return tenancyInfoMapper.insertTenancyInfo(tenancyInfo);
    }

    /**
     * 修改租户信息
     * 
     * @param tenancyInfo 租户信息
     * @return 结果
     */
    @Override
    public int updateTenancyInfo(TenancyInfo tenancyInfo)
    {
        return tenancyInfoMapper.updateTenancyInfo(tenancyInfo);
    }

    /**
     * 批量删除租户信息
     * 
     * @param ids 需要删除的租户信息主键
     * @return 结果
     */
    @Override
    public int deleteTenancyInfoByIds(Long[] ids)
    {
        return tenancyInfoMapper.deleteTenancyInfoByIds(ids);
    }

    /**
     * 删除租户信息信息
     * 
     * @param id 租户信息主键
     * @return 结果
     */
    @Override
    public int deleteTenancyInfoById(Long id)
    {
        return tenancyInfoMapper.deleteTenancyInfoById(id);
    }
   public void checkTenancyInfoAllow(TenancyInfo tenancyInfo){
        if(tenancyInfo.getId().equals(1)){
            throw new ServiceException("不允许修改系统管理租户");
        }
    }
}
